﻿<%@ Control Language="C#" AutoEventWireup="false" CodeFile="Deferments.ascx.cs" Inherits="Controls_Deferments" %>
<style>
cool\:tip{behavior: url(/Include/HTC/cooltip_js.htc)}
TABLE.GridView.Bridge TH INPUT.Filter{	text-transform:uppercase;	behavior1: url(/Include/HTC/TipMe.htc)}
CAPTION {BEHAVIOR: url(/Include/HTC/Toggle.htc);COLOR:navy;FONT-WEIGHT:bold}
TABLE.GridView TD.BorderRight{	border-right-width:1px;	border-right-color: Black}
TABLE.GridView TD.NextDue{background-color:#F5F5F5}
TABLE.GridView TD.Red{background-color:#FFE5E5}
TABLE.GridView TD.RedDark{color:#B80000}
TABLE.GridView TD.GreenDark{color:#006600}
TABLE.GridView TD.U A{color:black;text-decoration:none}
TABLE.GridView TD.U A.Bold{font-weight:bold}
TABLE.GridView TR TD,TH {font-size:<%=ddlFontSize.SelectedValue%>}
TABLE.Big TD,TH {font-size:<%=ddlFontSize.SelectedValue%>}
.Big{font-size:<%=ddlFontSize.SelectedValue%>}
.button INPUT {overflow:visible;padding:0px 3px;vertical-align:middle}
.button SELECT {vertical-align:middle}
SPAN.CheckBox INPUT{border:none;vertical-align:middle}
</style>
<div id="divGrid"><!-- Bridge -->
<asp:UpdatePanel ID="upBridge" UpdateMode="Always" runat="server">
<Triggers>
	<asp:PostBackTrigger ControlID="btnExcel" />
<asp:PostBackTrigger ControlID="ddlFontSize" />
</Triggers>
<ContentTemplate>
<asp:ObjectDataSource ID="dsUsersCached" SelectMethod="GetUsers" runat="server" />
<span class="button">
<asp:DropDownList id="ddlUsers" DataSourceID="dsUsersCached" DataTextField="Nick" DataValueField="UserName" runat="server" AutoPostBack="true" AppendDataBoundItems="true"
		 OnDataBound="ddlUsers_DataBound" OnSelectedIndexChanged="ddlUsers_SelectedIndexChanged"
>
<asp:ListItem Text ="Self" Value=""></asp:ListItem>
</asp:DropDownList>
<asp:Button ID="btnSaveFilter" OnClientClick="if(!saveFilter())return false;" CommandName="SaveFilter" runat="server" Text="Save Filter" />
<asp:DropDownList ID="ddlFilters" DataSourceID="dsFilters" DataTextField="Name" DataValueField="Value" AutoPostBack="true" runat="server"
		 OnPreRender="ddlFilters_PreRender" OnSelectedIndexChanged="ddlFilters_SelectedIndexChanged"
></asp:DropDownList>
<DS:ProfileFiltersDataSource ID="dsFilters" runat="server">
<SelectParameters>
<asp:ControlParameter PropertyName="FilterUser" Name="UserName" Type="String" DefaultValue="" />
</SelectParameters>
</DS:ProfileFiltersDataSource>
<asp:Button ID="btnDeleteFilter" CommandName="DeleteFilter" runat="server" Text="Delete Filter" />
<asp:ImageButton ID="btnExcel" ImageUrl="/Manager/Menu/Images/Excel.gif" CommandName="Excel"  runat="server" />
</span>
<br />
<span title="Change Font Size">
<asp:DropDownList ID="ddlFontSize" style="background-color:#D1FFDC;vertical-align:middle" AutoPostBack="true" runat="server">
<asp:ListItem Text="100%" Value="100%" />
<asp:ListItem Text="120%" Value="120%" Selected="True" />
<asp:ListItem Text="140%" Value="140%" />
<asp:ListItem Text="160%" Value="160%" />
</asp:DropDownList>
</span>
Date Since:<asp:TextBox ID="txtDateSince" AutoPostBack="true" runat="server" />
<asp:Label style="font-size:85%" id="lblCaption" runat="server"></asp:Label>
<DS:DefermentCandidates ID="ds" runat="server">
	<SelectParameters>
		<asp:ControlParameter ControlID="txtDateSince" PropertyName="Text" Name="PaymentDateMin" ConvertEmptyStringToNull="true" DefaultValue="1/1/2008" Type="DateTime" />
	</SelectParameters>
</DS:DefermentCandidates>
<UI:GridViewMB ID="grv" runat="server" AutoGenerateColumns="False" DataSourceID="ds" style="width:100%" ShowDelete="false" AllowEdit="false"
	AllowSorting="True"	DataKeyNames="LoanID,UsixID,CompanyID" EnableViewState="false" ShowFooter="false" EmptyDataRowStyle-Font-Bold="true" EmptyDataText="No comments"
	RowStyle-VerticalAlign="Top" OnRowClick="void(LoanID)" RowStyle-CssClass="Notes" OnSearchChanged="grv_SearchChanged"
	>
	<Columns>
	<asp:BoundField DataField="LoanID" HeaderText="LoanID" SortExpression="LoanID" />
	<asp:BoundField DataField="UsixID" HeaderText="UsixID" SortExpression="UsixID" />
	<asp:BoundField DataField="CompanyID" HeaderText="U" SortExpression="CompanyID" />
	<asp:BoundField DataField="Total Principal" HeaderText="Balance" SortExpression="Total Principal" />
	<asp:BoundField DataField="DSLP" HeaderText="DSLP" SortExpression="DSLP" />
	<asp:BoundField DataField="DPD" HeaderText="DPD" SortExpression="DPD" />
	<asp:BoundField DataField="DPD_Avg" HeaderText="Avg" SortExpression="DPD_Avg" ItemStyle-BackColor="WhiteSmoke" />
	<asp:BoundField DataField="DPD_StDev" HeaderText="StDev" SortExpression="DPD_StDev" ItemStyle-BackColor="WhiteSmoke" />
	<asp:BoundField DataField="Count" HeaderText="Count" SortExpression="Count" ItemStyle-BackColor="WhiteSmoke" />
	<asp:BoundField DataField="DefermentDate" HeaderText="<span title='Deferment Date(Last)'>DDt</span>" HtmlEncode="false" SortExpression="DefermentDate" DataFormatString="{0:d}" ItemStyle-BackColor="Azure" />
	<asp:BoundField DataField="DeferedDays" HeaderText="<span title='Deferment Days(Total)'>DDs</span>"  HtmlEncode="false" SortExpression="DeferedDays" ItemStyle-BackColor="Azure" />
	<asp:BoundField DataField="DeferementCount" HeaderText="<span title='Deferment Count'>DCnt</span>"  HtmlEncode="false" SortExpression="DeferementCount" ItemStyle-BackColor="Azure" />
	<asp:BoundField DataField="G_L Date" HeaderText="G_L Date" SortExpression="G_L Date" DataFormatString="{0:d}" />
	<asp:BoundField DataField="Pymnt Schedule" HeaderText="<span title='Payments Schedule'>PS</span>"  HtmlEncode="false" SortExpression="Pymnt Schedule" />
	<asp:BoundField DataField="# of PaymentsM" HeaderText="<span title='Total Payments'>TP</span>"  HtmlEncode="false" SortExpression="# of PaymentsM" DataFormatString="{0:0}" />
	<asp:BoundField DataField="PaymentsMadeM" HeaderText="<span title='Payments Made'>PM</span>"  HtmlEncode="false" SortExpression="PaymentsMadeM" DataFormatString="{0:0}" />
	<asp:BoundField DataField="# Pmts RemainingM" HeaderText="<span title='Payments Remaining'>PR</span>"  HtmlEncode="false" SortExpression="# Pmts RemainingM" DataFormatString="{0:0}" />
	<asp:BoundField DataField="Simple_Add-On" HeaderText="<span title='Loan Type'>LT</span>"  HtmlEncode="false" SortExpression="Simple_Add-On" />
	<asp:BoundField DataField="SSN" HeaderText="SSN" SortExpression="SSN" />
	<asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
	</Columns>
</UI:GridViewMB>
</ContentTemplate></asp:UpdatePanel>
</div>
<asp:UpdatePanel ID="upColl" UpdateMode="Always" runat="server"><ContentTemplate>
<UI:CollectionInfo ID="CollectionInfo" runat="server" />
</ContentTemplate></asp:UpdatePanel>

<loan:Payments runat="server" />
<UI:Notes ID="Notes" runat="server" />
<cool:tip delay="700" avoidMouse="true" duration="60"></cool:tip>
<asp:HiddenField id="hdnFilterName" OnPreRender="ScriptLocal" runat="server" />
<asp:HiddenField id="hdnFilterUser" OnPreRender="ScriptLocal" runat="server" />
<script>
window.onerror = function(){return event.returnValue = true;}
pageLoads.push(GVX_InitHeader);
setInterval(function(){showExpiration();},1*1000);
function InitHeader(){
	var inputs = divGrid.all.tags("INPUT");
	for( var i=0 ; i < inputs.length; i++ ){
		if( inputs[i].type != "text" )continue;
		inputs[i].onkeypress = null;
		inputs[i].delay = 700;
		inputs[i].coolTip = inputs[i].title.replace(/\r\n/g,"<br>");
		inputs[i].title = "";
		inputs[i].onmouseover = function(){
			event.srcElement.style.position = "relative";
			event.srcElement.style.zIndex=1000;
			event.srcElement.style.backgroundColor="white";
			showTip(this);
		};
		inputs[i].onmouseout = function(){
			event.srcElement.style.position = "";
			event.srcElement.style.zIndex=null;
			event.srcElement.style.backgroundColor="";
		};
	}
}
function showTip(el){
//el.coolTip = "Dimok";
	var tip = ((el.coolTip||"").match(/.+?<br>(.+)/)||new Array("",""))[1];
	el.coolTip = (el.value.fontcolor("navy").bold() + "<br>" + tip.replace(/(XXX|YYY|ZZZ)/g,"$1".fontcolor("#B80000").bold()));//.fontsize(3);
}
function showActivity(){
	showModelessDialog("/manager/collection/activity.aspx");
}
function showExpiration(){
	if( typeof(tdCollectionExpiration) == 'undefined' )return;
	WSA.Admin.GetLockInfo(cb);
	function cb(result){
		var rs = getRSFromDS(result,"Locks");
		var expMessage = "Session Expired".bold().fontcolor("maroon");
		if( rs != null ){
			var expDate = new Date("1/1/1900 "+rs("ExpiresIn").value);
			if( expDate.getMinutes() == 0 && expDate.getSeconds() <= 60 ){
				if( !showExpiration.expPopupShown ){
					showExpiration.expPopupShown = true;
					return refreshExpiration();
				}					
			}else showExpiration.expPopupShown = false;
			expMessage = "Expires In".bold()+"<br>"+rs("ExpiresIn");
		}
		try{
			if( !tdCollectionExpiration.onclick )tdCollectionExpiration.onclick = function(){btnRefresh().click();}
			tdCollectionExpiration.innerHTML = expMessage;
		}catch(e){status = e.description;}
	}
}
function refreshExpiration(){
	if( !confirm("You have less then a minute before session for current Loan expires.\nDo you wish to prolong it?" ) )return false;
		btnRefresh().click();
		true;
}
</script>
<?XML:NAMESPACE PREFIX="COOL" />
